package me.haoliang

/**
  * author: planck 
  * createTime: 2016/10/13.
  * http://www.runoob.com/scala/scala-options.html
  */
object OptionScala {

  def main(args: Array[String]): Unit = {
    val myMap: Map[String, String] = Map("aa" -> "heihei")

    val aa = myMap.get("aa")
    val bb = myMap.get("bb")

    println(aa)
    println(bb)

    println(show(aa))
    println(show(bb))

    println(aa.getOrElse("none"))
    println(bb.getOrElse("none"))

    println(aa.isEmpty)
    println(bb.isEmpty)

  }

  def show(x: Option[String]): String = {
    x match {
      case Some(s) => s
      case None => "none"
    }
  }
}
